package com.example.springAop.com.demo.jdkDynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
//代理对象
public class AccountAdvice implements InvocationHandler {
    //目标对象
    private IAccountService target;

    public AccountAdvice(IAccountService target){
        this.target = target;
    }

    /**
     * 代理方法，每次调用目标方法时都会进到这里
     * @param proxy
     * @param method
     * @param args
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        return method.invoke(target, args);
    }


    private void before(){
        System.out.println("对转账人身份进行验证");
    }




}
